/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package swa.e_store.entity;

import java.io.Serializable;
import javax.persistence.*;

/**
 * This class represents the table 'article' of the 'SWArchitecture' database.
 * 
 * @author Stefan
 */
@Entity
@Table (name = "article")
@NamedQueries({
    @NamedQuery(name = "article.findAll", query = "SELECT a FROM Article a"),
    @NamedQuery(name = "article.findByOffer", query = "SELECT a FROM Article a WHERE a.offerId = :offerId")
})
public class Article implements Serializable {
    
    //Variables comparing to the attributes of the table
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column (name="artNbr")
    private int artNbr;
    
    @Column (name="description", nullable = false)
    private String description;
    
    @Column (name = "price", nullable = false)
    private float price;
    
    @Column (name = "offerId")
    private int offerId;
    
    
    /**
     * Empty standard-constructor. Needed by JPA for bean interaction!
     */
    public Article(){
        
    }
    
    /**
     * Constructor for standard initialization.
     */
    public Article(int artNbr, String description, float price, int offerId){
        
        this.artNbr = artNbr;
        this.description = description;
        this.price = price;
        this.offerId = offerId;
    }
    
    //Getter & Setter

    /**
     * @return the artNbr
     */
    public int getArtNbr() {
        return artNbr;
    }

    /**
     * @param artNbr the artNbr to set
     */
    public void setArtNbr(int artNbr) {
        this.artNbr = artNbr;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the price
     */
    public float getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(float price) {
        this.price = price;
    }

    /**
     * @return the offerId
     */
    public int getOfferId() {
        return offerId;
    }

    /**
     * @param offerId the offerId to set
     */
    public void setOfferId(int offerId) {
        this.offerId = offerId;
    }
    
    // New implementation of toString()

    @Override
    public String toString(){
        return "article[artNbr: " + artNbr + ", description: " + description +
                ", price: " + price + ", offerId: " + offerId + "]\n";
    }
    
}
